package com.ctshk.common.model;

import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.Collections;
import java.util.List;

/**
 * @description
 * @author 谢诗宏
 * @date 2020/12/28
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class PageResponse<T> implements Serializable {

    @ApiModelProperty(name = "records", value = "分页数据")
    private List<T> records;

    @ApiModelProperty(name = "isFirst", value = "是否第一页",example = "true")
    private Boolean isFirst;

    @ApiModelProperty(name = "isLast", value = "是否最后一页",example ="false")
    private Boolean isLast;

    @ApiModelProperty(name = "total", value = "总数")
    private long total;

    @ApiModelProperty(name = "total", value = "当前页数")
    private long pageNo;

    @ApiModelProperty(name = "pageSize", value = "每页显示条数",example = "10")
    private long pageSize;

    public static <T> PageResponse<T> empty(long pageNo) {
        return new PageResponse<T>(null, pageNo == 1, true, 0, pageNo, 0);
    }

}